//
//  SWWebViewViewController.m
//  DataTransfer
//
//  Created by 宋润理 on 2023/12/22.
//  Copyright © 2023 James. All rights reserved.
//

#import "SWWebViewViewController.h"
#import <WebKit/WebKit.h>


@interface SWWebViewViewController ()

@property (nonatomic, copy) NSString *url;
@property (nonatomic, strong) WKWebView *webView;

@end

@implementation SWWebViewViewController

- (instancetype)initWithUrl: (NSString *)url
{
    self = [super init];
    if (self) {
        [self setUrl:url];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"查询序列号";
    [self setLeftItemWithIcon:[UIImage imageNamed:@"back"] title:nil selector:@selector(onClickBack)];
    [self.view addSubview:self.webView];
    [_webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(0));
    }];
}

- (void)onClickBack {
    [self.navigationController popViewControllerAnimated:YES];
}

- (WKWebView *)webView{
    if(!_webView){
        _webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:[WKWebViewConfiguration new]];
    }
    return _webView;
}

- (void)setUrl:(NSString *)url {
    _url = url;
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}

@end
